<script src="components/com_pgb/public/uploadlib/jquery.min.js" type="text/javascript"></script>
<script src="components/com_pgb/public/uploadlib/jquery.uploadify.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="components/com_frmessage/public/uploadlib/uploadify.css"/>

<script type="text/javascript" src="../media/system/js/jQuery.vietvang.validate.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$('#adminForm').validate({
			});
		});
</script>


<?php 
   $options = array(
       'onActive' => 'function(title, description){
           description.setStyle("display", "block");
           title.addClass("open").removeClass("closed");
       }',
       'onBackground' => 'function(title, description){
           description.setStyle("display", "none");
           title.addClass("closed").removeClass("open");
       }',
       'startOffset' => 0,  // 0 starts on the first tab, 1 starts the second, etc...
       'useCookie' => true, // this must not be a string. Don't use quotes.
   );
?>
    <form action="index.php?option=com_pgb" method="post" name="adminForm" id="adminForm" class="adminform" enctype="multipart/form-data">
<table style="width:100%" border=0> 
    <tr>
      <td></td>
      <td class="err"><label>※印は入力必須項目です。</label></td>
   </tr>
   <tr>
      <td style="width: 160px;"><label>センター・クラブコード<span class='err'>※</span></label></td>
      <td style="width: 180px;">
            <input type="text" vvName="number" data_required="true"  id="jformOCBA_CODE" name="jform[OCBA_CODE]" value="<?php echo $this->data['OCBA_CODE']; ?>" class = "inputbox medium" onchange = "centerName(this.value);checkCenter(this.value);" /><a href="#" id="link_ocba_code" >検索</a>
            <input type="hidden" name="ocba_code_old" id="ocba_code_old" value="<?php echo $this->ocba_code_old; ?>" />
            <input type="hidden" name="addnew" id="addnew" value="<?php echo $this->addnew; ?>" />
            <span name="msg_error"></span>
            
      </td>
      <td colspan="2"><input type="text" id="jformOCBA_NAME" value="<?php echo $this->ocba_name; ?>" class="inputbox big" disabled="true"/> </td>
   </tr>
   <tr>
   <td></td>
    <td colspan="3" id="resultCheck"></td>
   </tr>
   <tr id="mess">
        <td></td>
        <td colspan="3" style="color: red;">センター・クラブを選択してください。</td>
   </tr>

</table>   
<?php echo JHtml::_('tabs.start', 'tab_group_id', $options); ?>

<?php echo JHtml::_('tabs.panel', JText::_('プール'), 'panel_1_id'); ?>

<div id="panel_1">
<table id="table_club_1" border=0 style="width:940px">
   <tr>
      <td style="min-width:120px"></td>
      <td style="min-width:210px"></td>
      <td style="min-width:100px"></td>
      <td style="min-width:210px"></td>
      <td style="min-width:300px"></td>
  </tr>
<!--   <tr>
  <td style="width: 160px"></td>
  <td style="width: 160px"></td>
  <td style="width: 400px"></td>
  <td style="width: 160px"></td>
  <td></td>
</tr> -->
   <tr>
      <td colspan="5"><img src="templates/toppage-BG/images/square.jpg"  style="width: 8px; height: 8px;" /> プール</td>
   </tr>
   <tr>
        <td style="text-align: right;font-size: 1.091em;padding-right:5px;visibility: hidden">プールコード</td>
        <td colspan="4" >  
        </td>
   </tr>
   <tr>
     <!--  <td style="text-align: right;font-size: 1.091em;padding-right:5px;">運営委託業者<span class='err'></span></td> -->
      <td style="text-align: right;font-size: 1.091em;padding-right:5px;">運営委託業者</td>
      <td colspan="4"> 
        <input type="text" class="input medium"  name="jform[POOL_ADMN]" value="<?php echo $this->data['POOL_ADMN']; ?>" style="width: 58%;" />
        
      </td>
        
   </tr>
   <tr style="vertical-align:top">
      <td style="text-align: right;font-size: 1.091em;padding-right:5px;line-height:30px;">開設日</td>
      <td >
        <?php echo JHtml::calendar($this->data['POOL_SDATE'], 'jform[POOL_SDATE]', 'jformPOOL_SDATE');?>  
        <span name="msg_error"></span>  
      </td>
      <td style="font-size: 1.091em;line-height:30px;" class="text-align">譲渡日</td>
      <td >
        <?php echo JHtml::calendar($this->data['POOL_TDATE'], 'jform[POOL_TDATE]', 'jformPOOL_TDATE');?>
        <span name="msg_error"></span>      
      </td>
      <td></td>
   </tr>
   <tr>
      <td style="text-align: right;font-size: 1.091em;padding-right:5px;">プール種別<span class='err'></span></td>
      <td>
        <?php if(isset($this->data['POOL_POLK'])){ ?>
            <select id="jform-pool-polk" name="jform[POOL_POLK]" class="medium">
              <option value="">選択してください</option>
            <?php foreach($this->poolType as $key=>$value){ ?>
            	<option value="<?php echo $key ?>" ><?php echo $value ?></option>
            <?php } ?>
            </select>
        <?php }else{ ?>
            <select id="jform-pool-polk" name="jform[POOL_POLK]" class="medium">
              <option value="">選択してください</option>
            <?php foreach($this->poolType as $key=>$value){ ?>
            	<option value="<?php echo $key ?>" ><?php echo $value ?></option>
            <?php } ?>
            </select>
        <?php } ?>
      </td>
      <td style="font-size: 1.091em;line-height:30px;vertical-align:top" class="text-align">廃止日</td>
      <td style="vertical-align:top">
        <?php echo JHtml::calendar($this->data['POOL_EDATE'], 'jform[POOL_EDATE]', 'jformPOOL_EDATE');?>
        <span name="msg_error"></span> 
      </td>
      <td></td>
   </tr>
   <tr>
      <td style="text-align: right;font-size: 1.091em;padding-right:5px;">温水種別<span class='err'></span></td>
      <td colspan="3"> 
        <?php if(isset($this->data['POOL_POHK'])){ ?>
            <select id="jform-pool-pohk" name="jform[POOL_POHK]" class="medium">
              <option value="">選択してください</option>
            <?php foreach($this->poolHolk as $key=>$value){ ?>
            	<option value="<?php echo $key ?>" <?php if($key == $this->data['POOL_POHK']){ echo "selected"; } ?>><?php echo $value ?></option>
            <?php }?>
            </select>
        <?php }else{ ?>
            <select id="jform-pool-pohk" name="jform[POOL_POHK]" class="medium">
              <option value="">選択してください</option>
            <?php foreach($this->poolHolk as $key=>$value){ ?>
            	<option value="<?php echo $key ?>"><?php echo $value ?></option>
            <?php }?>
            </select>
        <?php } ?>
      </td>
      <td></td>
   </tr>
   <tr>
    <td style="text-align: right;font-size: 1.091em;padding-right:5px;">開館期間<span class='err'></span></td>
    <td colspan="3">
        <input type="text"  name="jform[POOL_TERM]" value="<?php echo $this->data['POOL_TERM']; ?>" style="width: 58%;" />
    </td>
    <td></td>
   </tr>
    <tr>
        <td colspan="5">
            <fieldset id="adminformfieldset">
               <legend>設備</legend>
               <table id="table_device_list" border=0 style="width:940px !important" >
                  <tr>
                     <td style="padding-top:10px;text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;width: 11%;" >拡張施設<span class='err'></span></td>
                     <td colspan="4">
                        
                        <table style="width: 100%;" border=0>
                            <?php
                                
                                $tbpo_list = $this->tbpo_list;
                                if($tbpo_list != null){ $tbpo_list = explode(",",$tbpo_list); }
                                if($this->extendFac != null){
                                    foreach($this->extendFac as $k=>$value){
                                        if($k%4 == 0){
                                            echo "<tr>";
                                        }
                                        if(empty($tbpo_list))
                                            $checked = "";
                                        else
                                            $checked = array_search($value->TBPO_CODE, $tbpo_list) !== false ? "checked" : "";
                                        echo "<td><input type='checkbox' style='float:right;' name='cbfac$value->TBPO_CODE' id='cbfac$value->TBPO_CODE' value='$value->TBPO_CODE' $checked/></td>";
                                        echo "<td><label for='cbfac$value->TBPO_CODE'>$value->TBPO_NAME</label></td>";                                            
                                        
                                        if($k%4 == 3){
                                            echo "</tr>";
                                        }
                                    }
                                }
                             ?>  
                        
                        </table>
                     </td>
                     
                     
                  </tr>
                  <tr>
                    <td colspan="5"><br /></td>
                  </tr>
                  <tr>
                     <td style="padding-top:10px;text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;" >バリアフリー<span class='err'></span></td>
                     <td colspan="4">                        
                        <table style="width: 100%;" border=0>
                            <?php
                                
                                $list_disp_pool = $this->list_disp_pool;
                                if($list_disp_pool != null){ $list_disp_pool = explode(",",$list_disp_pool); }
                                if($this->disabled != null){
                                    foreach($this->disabled as $k=>$value){
                                        if($k%4 == 0){
                                            echo "<tr>";
                                        }
                                        if(empty($tbpo_list))
                                            $checked = "";
                                        else
                                            $checked = array_search($value->DISP_CODE, $tbpo_list) !== false ? "checked" : "";
                                        echo "<td><input type='checkbox' style='float:right;' name='cbdis$value->DISP_CODE' id='cbdis$value->DISP_CODE' value='$value->DISP_CODE' $checked/></td>";
                                        echo "<td><label for='cbdis$value->DISP_CODE'>$value->DISP_NAME</label></td>";                                            
                                        
                                        if($k%4 == 3){
                                            echo "</tr>";
                                        }
                                    }
                                }
                             ?>  
                        
                        </table>
                        
                     </td>
                  </tr>
                  <tr>
            		<td style="float:right !important;width:50px;line-height: 22px;font-size: 1.091em;width:65px" >施設利用<span class='err'></span></td>
            		<td colspan="4">
                    <?php if(isset($this->data['POOL_METK'])){ ?>
                        <select id="jform-pool-metk" name="jform[POOL_METK]" class="medium" >
                          <option value="9">選択してください</option>
                            <?php foreach($this->poolMetk as $key=>$value){ ?>
                    	       <option value="<?php echo $key ?>" <?php if($key == $this->data['POOL_METK']){ echo "selected"; } ?> ><?php echo $value ?></option>
                            <?php }?>
                        </select>
                    <?php }else{ ?>
                        <select id="jform-pool-metk" name="jform[POOL_METK]" class="medium">
                          <option value="9">選択してください</option>
                            <?php foreach($this->poolMetk as $key=>$value){ ?>
                    	       <option value="<?php echo $key ?>" ><?php echo $value ?></option>
                            <?php }?>
                        </select>
                    <?php } ?>
                    </td>
            		
            	</tr>
                </table>
            </fieldset>
        </td>
    </tr>
	
    <tr>
     <td colspan="5">
    <fieldset id="adminformfieldset">
   
       <legend>料金</legend>
       <table id="table_fee_list" border=0 style="width:940px" >
          <tr style="visibility:hidden">
              <td style="min-width:105px"></td>
              <td style="min-width:210px"></td>
              <td style="min-width:100px"></td>
              <td style="min-width:210px"></td>
              <td style="min-width:286px"></td>
          </tr>
          <tr style="vertical-align:top;">
             <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px;" >町内大人</td>
             <td style="width: 38%" > 
                <input  type="text" vvName="money" value="<?php echo $this->data['POOL_CIAD']; ?>" id="jform-pool-ciad" name="jform[POOL_CIAD]"  class="inputbox medium" />
                <span name="msg_error"></span>
             </td>
             <td style="text-align: right;font-size: 1.091em;padding-right:5px;width:100px;vertical-align:top;line-height:30px;">町内子供</td>
             <td>
                <input type="text" vvName="money"  value="<?php echo $this->data['POOL_CICI']; ?>" class="inputbox medium" id="jform-pool-cici"  name="jform[POOL_CICI]" />
                <span name="msg_error"></span>
             </td>
          </tr>
          <tr style="vertical-align:top;">
             <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px;">町外大人</td>
             <td>
                <input type="text" vvName="money" value="<?php echo $this->data['POOL_COAD']; ?>" class="inputbox medium" id="jform-pool-coad" name="jform[POOL_COAD]" />
                 <span name="msg_error"></span>
             </td>
             <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px;">町外子供</td>
             <td>
                <input type="text" vvName="money" value="<?php echo $this->data['POOL_COCI']; ?>" class="inputbox medium" id="jform-pool-coci" name="jform[POOL_COCI]" />
                <span name="msg_error"></span>
            </td>
                
          </tr>
          <td style="text-align: right;font-size: 1.091em;padding-right:5px;">備考</td>
          <td colspan="3"> <input class="input medium" type="text" value="<?php echo $this->data['POOL_CNOT']; ?>" id="jform-pool-cnot" name="jform[POOL_CNOT]" style="width: 84%;" /></td>
       </table>
    </fieldset>
    </td>
    </tr>
    <tr>
        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">備考</td>
        <td colspan="3"> <textarea id="jform-pool-note" name="jform[POOL_NOTE]" style="width: 60.5%;"><?php echo $this->data['POOL_NOTE']; ?></textarea></td>
        <td></td>
    </tr>   

</table>
</div>

   <?php echo JHtml::_('tabs.panel', JText::_('体育館'), 'panel_2_id');?>
<div id="panel_2">
    <table id="gymnasium_list1" style="width: 100%;" border=0>
    <tr>
      <td style="width: 160px"></td>
      <td style="width: 200px"></td>
      <td style="width: 150px"></td>
      <td style="width: 200px"></td>
      <td style="width: 532px" ></td>
    </tr>
    <tr>
        <td colspan="5">
        <?php if(isset($this->data['GYMT_2NDK'])){ ?>
            <span class='err' style="line-height:30px"></span><select id="jform-gymt_2ndk" name="jform[GYMT_2NDK]">
            <?php foreach($this->gym as $key=>$value){ ?>
    	       <option value="<?php echo $key ?>" <?php if($key == $this->data['GYMT_2NDK']) echo "selected";?> ><?php echo $value ?></option>
            <?php } ?>
            </select>
        <?php }else{ ?>
            <span class='err' style="line-height:30px"></span><select id="jform-gymt_2ndk" name="jform[GYMT_2NDK]">
            <?php foreach($this->gym as $key=>$value){ ?>
    	       <option value="<?php echo $key ?>" <?php if($key == 1) echo "selected";?> ><?php echo $value ?></option>
            <?php } ?>
            </select>
        <?php } ?>
        </td>
    </tr>
    <tr>
        <td colspan="5" style="font-size: 1.091em;"><img src="templates/toppage-BG/images/square.jpg" style="width: 8px; height: 8px;" />第一体育館</td>
    </tr>
    <tr style="visibility:hidden">
        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">第一体育館コード</td>
        <td colspan="4">
        </td>  
    </tr>
    <tr>
        <!-- <td style="text-align: right;font-size: 1.091em;padding-right:5px;">運営委託業者<span class='err'></span></td> -->
        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">運営委託業者</td>
        <td colspan="4"> <input class="input medium"  type="text" value="<?php echo $this->data['GYMT_ADMN1']; ?>" id="jform-gymt-admn1" name="jform[GYMT_ADMN1]" style="" /></td>
       
    </tr>
    <tr style="vertical-align:top">
        <td style="text-align: right;font-size: 1.091em;padding-right:5px; line-height: 30px">開設日</td>
        <td >
            <?php echo JHtml::calendar($this->data['GYMT_SDATE1'], 'jform[GYMT_SDATE1]', 'jformGYMT_SDATE1');?>
            <span name="msg_error"></span>
        </td>
        <td style="font-size: 1.091em; line-height:30px;" class="text-align">譲渡日</td>
        <td style="">
            <?php echo JHtml::calendar($this->data['GYMT_TDATE1'], 'jform[GYMT_TDATE1]', 'jformGYMT_TDATE1');?>
            <span name="msg_error"></span>
        </td>
        <td></td>
    </tr>
    
    <tr>
        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">ミーティングルーム種別<span class='err'></span></td>
        <td>
        <?php if(isset($this->data['GYMT_METK1'])){ ?>
            <select id="jform-gymt-metk1" name="jform[GYMT_METK1]" class="medium">
              <option value="">選択してください</option>
                <?php foreach($this->gymtMetk as $key=>$value){ ?>
        	       <option value="<?php echo $key ?>" <?php if($key == $this->data['GYMT_METK1']) echo "selected";?> ><?php echo $value ?></option>
                <?php }?>
            </select>
        <?php }else{ ?>
            <select id="jform-gymt-metk1" name="jform[GYMT_METK1]" class="medium">
              <option value="">選択してください</option>
                <?php foreach($this->gymtMetk as $key=>$value){ ?>
        	       <option value="<?php echo $key ?>" ><?php echo $value ?></option>
                <?php }?>
            </select>
        <?php } ?>
        </td>
        <td class="right" style="font-size: 1.091em; line-height: 30px; vertical-align: top">廃止日</td>
        <td>
            <?php echo JHtml::calendar($this->data['GYMT_EDATE1'], 'jform[GYMT_EDATE1]', 'jformGYMT_EDATE1');?>
            <span name="msg_error"></span>
        </td>
        <td></td>
    </tr>
    <tr>
        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">バリアフリー<span class='err'></span></td>
        <td colspan="4">
            
            <table style="" border=0>
                <?php
                    
                    $list_disabled_gymt = $this->list_disabled_gymt;
                    if($list_disabled_gymt != null){ $list_disabled_gymt = explode(",",$list_disabled_gymt); }
                    if($this->listDisabledGymt != null){
                        foreach($this->listDisabledGymt as $k=>$value){
                            if($k%4 == 0){
                                echo "<tr>";
                            }
                            if(empty($list_disabled_gymt))
                                $checked = "";
                            else
                                $checked = array_search($value->TBGY_CODE, $list_disabled_gymt) !== false ? "checked" : "";
                            echo "<td><input type='checkbox' style='float:right;' name='cbdisgym$value->TBGY_CODE' id='cbdisgym$value->TBGY_CODE' value='$value->TBGY_CODE' $checked/></td>";
                            echo "<td><label for='cbdisgym$value->TBGY_CODE'>$value->TBGY_NAME</label></td>";                                            
                            
                            if($k%4 == 3){
                                echo "</tr>";
                            }
                        }
                    }
                 ?>  
            
            </table>
        </td>
    </tr>
    <tr>
        <td colspan="5">
            <fieldset id="adminformfieldset">
                <legend>料金</legend>
               <table id="table_fee_list" border=0>
                    <tr style="visibility:hidden">
                      <td style="width: 130px"></td>
                      <td style="width: 200px"></td>
                      <td style="width: 150px"></td>
                      <td style="width: 200px"></td>
                      <td style="width: 500px" ></td>
                    </tr>
                    <tr style="vertical-align:top;">
                        <td style="width: 12%; text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px;" >町内大人</td>
                       <td style="width: 150px" >
                            <input type="text" vvName="money" value="<?php echo $this->data['GYMT_CIAD1']; ?>" id="jform-gymt-ciad1" name="jform[GYMT_CIAD1]" class="inputbox medium" />
                            <span name="msg_error"></span>
                       </td>
                        <td style=" width: 150px;font-size: 1.091em;vertical-align:top;line-height:30px;" class="text-align">町内子供</td>
                        <td>
                            <input type="text"  vvName="money" value="<?php echo $this->data['GYMT_CICI1']; ?>" id="jform-gymt-cici1" name="jform[GYMT_CICI1]" class="inputbox medium" />
                            <span name="msg_error"></span>
                        </td>     
                    </tr>
                    <tr style="vertical-align:top;">
                        <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px;">町外大人</td>
                        <td>
                            <input type="text" vvName="money" value="<?php echo $this->data['GYMT_COAD1']; ?>" id="jform-gymt-coad1" name="jform[GYMT_COAD1]" class="inputbox medium" />
                            <span name="msg_error"></span>
                        </td>
                        <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px;">町外子供</td>
                        <td>
                            <input type="text" vvName="money" value="<?php echo $this->data['GYMT_COCI1']; ?>" id="jform-gymt-coci1" name="jform[GYMT_COCI1]" class="inputbox medium" />
                            <span name="msg_error"></span>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">備考</td>
                        <td colspan="3"> <input class="xbig" type="text" value="<?php echo $this->data['GYMT_CNOT1']; ?>" id="jform-gymt-cnot1" name="jform[GYMT_CNOT1]" style="" /></td>
                    </tr>
               </table>
            </fieldset>
        </td>
    </tr>
    <tr>
        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">備考</td>
        <td colspan="4"> <textarea id="jform-gymt-note1" name="jform[GYMT_NOTE1]" style="width: 56.5%;" ><?php echo $this->data['GYMT_NOTE1']; ?></textarea></td>
    </tr>
  </table>
  <!-- wrapper gym2 -->
  <br /> <br />
  <div id="wrapper-gym2" style="display: none;" >
  <table id="gymnasium_list2" style="width: 100%;" border=0>
    <tr style="visibility:hidden">
      <td style="width: 160px"></td>
      <td style="width: 200px"></td>
      <td style="width: 150px"></td>
      <td style="width: 200px"></td>
      <td style="width: 532px" ></td>
    </tr>
    <tr>
        <td colspan="5"><img src="templates/toppage-BG/images/square.jpg"  style="width: 8px; height: 8px;" />第二体育館</td>
    </tr>
     <tr style="visibility:hidden">
        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">第二体育館コード</td>
        <td colspan="4">
        </td>  
    </tr>
    <tr>
        <!-- <td style="text-align: right;font-size: 1.091em;padding-right:5px;">運営委託業者<span class='err'></span></td> -->
        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">運営委託業者</td>
        <td colspan="4"> <input class="input medium"  type="text" value="<?php echo $this->data['GYMT_ADMN2']; ?>" id="jform-gymt-admn2" name="jform[GYMT_ADMN2]" /></td>
        
    </tr>
    <tr style="vertical-align:top">
        <td style="text-align: right;font-size: 1.091em;padding-right:5px; line-height: 30px">開設日</td>
        <td >
            <?php echo JHtml::calendar($this->data['GYMT_SDATE2'], 'jform[GYMT_SDATE2]', 'jformGYMT_SDATE2');?>
            <span name="msg_error"></span>
        </td>
        <td class="text-align" style="vertical-align: top; line-height:30px;font-size: 1.091em;">譲渡日</td>
        <td>
            <?php echo JHtml::calendar($this->data['GYMT_TDATE2'], 'jform[GYMT_TDATE2]', 'jformGYMT_TDATE2');?>
            <span name="msg_error"></span>
        </td>
        <td></td>
    </tr>
    <tr style="vertical-align:top">
        <td colspan="3" class="right" style="vertical-align: top; line-height: 30px;font-size: 1.091em;">廃止日</td>
        <td>
            <?php echo JHtml::calendar($this->data['GYMT_EDATE2'], 'jform[GYMT_EDATE2]', 'jformGYMT_EDATE2');?>
            <span name="msg_error"></span>
        </td>
        <td></td>
    </tr>
    <tr>
        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">設備<span class='err'></span></td>
        <td colspan="4">
        
            <table style="width: 30%;" border=0>
                <tr>
                
            <?php
                 
                foreach($this->equipment as $key=>$value){?>
                <td><input type="checkbox" name="cbeq<?php echo $key; ?>" id="cbeq<?php echo $key; ?>" value="<?php echo $value; ?>"  <?php if(($key == 1 && $this->data['GYMT_MATF'] == 1) || ($key == 2 && $this->data['GYMT_MACF'] == 1)) { echo 'checked="checked"'; } ?>  /></td>
                <td><label for="cbeq<?php echo $key; ?>"><?php echo $value; ?></label></td>
            <?php }?>
            
                </tr>
            </table>
            
            
        </td>
    </tr>
    <tr>
        <td colspan="5">
            <fieldset class="adminform" id="adminformfieldset">
                <legend>料金</legend>
               <table id="table_fee_list" border=0>
                    <tr style="visibility:hidden">
                      <td style="width: 132px"></td>
                      <td style="width: 200px"></td>
                      <td style="width: 150px"></td>
                      <td style="width: 200px"></td>
                      <td style="width: 500px" ></td>
                    </tr>
                    <tr style="vertical-align:top;">
                        <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px;" >町内大人</td>
                       <td  >
                            <input type="text" vvName="money" value="<?php echo $this->data['GYMT_CIAD2']; ?>" id="jform-gymt-ciad2" name="jform[GYMT_CIAD2]" class="inputbox medium" />
                            <span name="msg_error"></span>
                       </td>
                        <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px;">町内子供</td>
                        <td>
                            <input type="text" vvName="money" value="<?php echo $this->data['GYMT_CICI2']; ?>" id="jform-gymt-cici2" name="jform[GYMT_CICI2]" class="inputbox medium" />
                            <span name="msg_error"></span>
                        </td>
                    </tr>
                    <tr style="vertical-align:top;">
                        <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px;">町外大人</td>
                        <td>
                            <input type="text" vvName="money" value="<?php echo $this->data['GYMT_COAD2']; ?>" id="jform-gymt-coad2" name="jform[GYMT_COAD2]" class="inputbox medium" />
                            <span name="msg_error"></span>
                        </td>
                        <td class="text-align" style="vertical-align:top;line-height:30px;">町外子供</td>
                        <td>
                            <input type="text" vvName="money" value="<?php echo $this->data['GYMT_COCI2']; ?>" id="jform-gymt-coci2" name="jform[GYMT_COCI2]" class="inputbox medium" />
                            <span name="msg_error"></span>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">備考</td>
                        <td colspan="3"> <input class="xbig" type="text" value="<?php echo $this->data['GYMT_CNOT2']; ?>" id="jform-gymt-cnot2" name="jform[GYMT_CNOT2]" /></td>
                    </tr>
               </table>
            </fieldset>
        </td>
    </tr>
    <tr>
        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">備考</td>
        <td colspan="4"> <textarea  id="jform-gymt-note2" name="jform[GYMT_NOTE2]"  class="input xbig" ><?php echo $this->data['GYMT_NOTE2']; ?></textarea></td>
    </tr>
  </table>
  </div><!-- end wrapper gym2 -->
</div>


   <?php echo JHtml::_('tabs.panel', JText::_('艇庫'), 'panel_3_id');?>
   <div id="panel_3">
       <table id="boathouse_list" border=0>
        <tr style="visiblility:hidden">
          <td style="width: 160px"></td>
          <td style="width: 220px"></td>
          <td style="width: 80px"></td>
          <td style="width: 220px"></td>
          <td style="width: 553px"></td>
        </tr>
<!--         <tr>
  <td style="width: 145px"></td>
  <td style="width: 200px"></td>
  <td style="width: 130px"></td>
  <td style="width: 200px"></td>
  <td style="width: 500px"></td>
</tr> -->
        <tr>
            <td colspan="5"><img src="templates/toppage-BG/images/square.jpg" style="width: 8px; height: 8px;" />艇庫</td>
            
        </tr>
        <tr style="visibility: hidden">
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">艇庫コード</td>
            <td colspan="4">
            </td>  
        </tr>
        <tr>
            <!-- <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px">運営委託業者<span class='err'></span></td> -->
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px">運営委託業者</td>
            <td colspan="4"><input class="input medium" type="text" value="<?php echo $this->data['DOCK_ADMN']; ?>" id="jform-dock-admn" name="jform[DOCK_ADMN]" /></td>  
        </tr>
        <tr style="vertical-align:top">
             <td style="text-align: right;font-size: 1.091em;padding-right:5px; vertical-align: top; line-height: 30px;">開設日</td>
             <td style="vertical-align:top" >
                <?php echo JHtml::calendar($this->data['DOCK_SDATE'], 'jform[DOCK_SDATE]', 'jformDOCK_SDATE');?>
                <span name="msg_error"></span> 
            </td>
             <td style="text-align: right;font-size: 1.091em; line-height:30px;vertical-align:top;line-height:30px">譲渡日</td>
             <td style="vertical-align:top">
                <?php echo JHtml::calendar($this->data['DOCK_TDATE'], 'jform[DOCK_TDATE]', 'jformDOCK_TDATE');?>
                <span name="msg_error"></span>
             </td>
             <td></td>
        </tr>
        <tr>
             <td style="text-align: right;font-size: 1.091em;padding-right:5px; vertical-align: top;line-height:30px">郵便番号</td>
             <td  >
                <input type="text" vvName="postcode" value="<?php echo $this->data['DOCK_POST']; ?>" id="jform-dock-post" name="jform[DOCK_POST]" class="inputbox medium" />
                <span name="msg_error"></span>
             </td>
             <td style="text-align: right;font-size: 1.091em; vertical-align: top ; line-height: 30px">廃止日</td>
             <td style="vertical-align:top">
                <?php echo JHtml::calendar($this->data['DOCK_EDATE'], 'jform[DOCK_EDATE]', 'jformDOCK_EDATE');?>
                <span name="msg_error"></span>
             </td>
             <td></td>
        </tr>
        <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">住所</td>
            <td colspan="4"><input class="input medium" type="text" value="<?php echo $this->data['DOCK_ADD1']; ?>" id="jform-dock-add1" name="jform[DOCK_ADD1]" /></td>  
        </tr>
        <tr>
             <td style="text-align: right;font-size: 1.091em;padding-right:5px; vertical-align: top; line-height: 30px" >TEL</td>
             <td>
                <input type="text" vvName="phone" value="<?php echo $this->data['DOCK_TEL']; ?>" id="jform-dock-tel" name="jform[DOCK_TEL]" class="inputbox medium" />
                <span name="msg_error"></span>
             </td>
             <td style="text-align: right;font-size: 1.091em; vertical-align: top; line-height: 30px">FAX</td>
             <td style="vertical-align:top">
                <input type="text" vvName="fax" value="<?php echo $this->data['DOCK_FAX']; ?>" id="jform-dock-fax" name="jform[DOCK_FAX]" class="inputbox medium" />
                <span name="msg_error"></span>
             </td>
             <td></td>
        </tr>
        <tr>
            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">開館期間</td>
            <td colspan="4"><input type="text" value="<?php echo $this->data['DOCK_TERM']; ?>" id="jform-dock-term" name="jform[DOCK_TERM]" style="width: 56.5%;" /></td>  
        </tr>
        <tr>
             <td style="text-align: right;font-size: 1.091em;padding-right:5px;">艇庫種別<span class='err'></span></td>
             <td>
                <select id="jform-dock-docm-code" name="jform[DOCK_DOCM_CODE]" class="inputbox medium">
                  <option value="">選択してください</option>
                    <?php foreach($this->boatType as $value){ ?>
            	       <option value="<?php echo $value->DOCM_CODE ?>" ><?php echo $value->DOCM_NAME?></option>
                    <?php }?>  
                </select>
             </td>
             <td style="text-align: right;font-size: 1.091em;">常勤者<span class='err'></span></td>
             <td>
                <select id="jform-dock-ftmf" name="jform[DOCK_FTMF]" class="medium">
                  <option value="9">選択してください</option>
                    <?php foreach($this->employee as $key=>$value){ ?>
        	           <option value="<?php echo $key ?>"><?php echo $value?></option>
                    <?php }?>  
                </select>
             </td>
             <td></td>
        </tr>
        <tr>
             <td style="text-align: right;font-size: 1.091em;padding-right:5px;" >利用予約<span class='err'></span></td>
             <td>
                    <select  id="jform-dock-dowm-code" name="jform[DOCK_RSVF]" class="input medium">
                      <option value="9">選択してください</option>
                        <?php foreach($this->listDock_rsvf as $key=>$value){ ?>
        	               <option value="<?php echo $key ?>" ><?php echo $value ?></option>
                        <?php }?> 
                    </select>
             </td>
             <td colspan="3"></td>
        </tr>
        <tr>
            <td colspan="5">
             <fieldset id="adminformfieldset">
                    <legend>設備</legend>
                   <table id="table_fee_list" border=0>
                        <tr>
                            <td style="text-align: right;font-size: 1.091em;padding-right:5px;width:140px;" >トイレ種別<span class='err'></span></td>
                            <td style="width: 150px" >
                               <select id="jform-dock-toyk" name="jform[DOCK_TOYK]" class="medium">
                                <option value="9">選択してください</option>
                                    <?php foreach($this->listDock as $key=>$value){ ?>
        	                           <option value="<?php echo $key ?>" ><?php echo $value?></option>
                                    <?php }?>  
                                </select>
                            </td>
                            <td  style="text-align: right;font-size: 1.091em;width:150px" >シャワー種別<span class='err'></span></td>
                            <td style="width:465px">
                                <select id="jform-dock-shwk" name="jform[DOCK_SHWK]" class="medium">
                                  <option value="9">選択してください</option>
                                    <?php foreach($this->listDock as $key=>$value){ ?>
        	                           <option value="<?php echo $key ?>"><?php echo $value?></option>
                                    <?php }?>  
                                </select>
                            </td>
                            <td style="width: 286px"></td>
                        </tr>
                        <tr>
                            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">温水シャワー種別<span class='err'></span></td>
                            <td>
                                <select id="jform-dock-shhk" name="jform[DOCK_SHHK]" class="medium">
                                  <option value="9">選択してください</option>
                                    <?php foreach($this->listDock as $key=>$value){ ?>
        	                           <option value="<?php echo $key ?>"><?php echo $value?></option>
                                    <?php }?>  
                                </select>
                            </td>
                            <td style="text-align: right;font-size: 1.091em;" >更衣室種別<span class='err'></span></td>
                            <td>
                                <select id="jform-dock-chak" name="jform[DOCK_CHAK]" class="medium">
                                  <option value="9">選択してください</option>
                                    <?php foreach($this->listDock as $key=>$value){ ?>
        	                           <option value="<?php echo $key ?>"><?php echo $value?></option>
                                    <?php }?>  
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right;font-size: 1.091em;padding-right:5px;" >駐車スペース種別<span class='err'></span></td>
                            <td colspan="3">
                                <select id="jform-dock-pakk" name="jform[DOCK_PAKK]" class="medium">
                                  <option value="9">選択してください</option>
                                    <?php foreach($this->listDock as $key=>$value){ ?>
        	                           <option value="<?php echo $key ?>"><?php echo $value?></option>
                                    <?php }?>  
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">バリアフリー<span class='err'></span></td>
                            <td colspan="3" >
                                <table style="width: 50%;" border=0>
                                    <?php
                                        
                                        if(isset($this->list_disabled_dock)){ $list_disabled_dock = explode(",",$this->list_disabled_dock); }
                                        foreach($this->listDisabledDock as $k => $value){
                                            if($k%3 == 0){
                                                echo "<tr>";
                                            }
                                            if(empty($list_disabled_dock))
                                                $checked = "";
                                            else
                                                $checked = array_search($value->TBDO_CODE, $list_disabled_dock) !== false ? "checked" : "";
                                            echo "<td><input type='checkbox' style='float:right;' name='cbdock$value->TBDO_CODE' id='cbdock$value->TBDO_CODE' value='$value->TBDO_CODE' $checked/></td>";
                                            echo "<td><label for='cbdock$value->TBDO_CODE'>$value->TBDO_NAME</label></td>";                                            
                                            
                                            if($k%3 == 2){
                                                echo "</tr>";
                                            }
                                        }
                                     ?>  
                                
                                </table>
                            </td>
                        </tr>
                   </table>
                </fieldset>    
            </td>
        </tr>
        <tr>
            <td colspan="5">
                <fieldset id="adminformfieldset">
                    <legend>水面</legend>
                   <table id="table_fee_list" border=0>
                        <tr>
                            <td style="text-align: right;font-size: 1.091em;padding-right:5px;width:12%" >水面区分<span class='err'></span></td>
                            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">
                                <select id="jform-dock-watm-code" name="jform[DOCK_WATM_CODE]" class="medium">
                                  <option value="">選択してください</option>
                                    <?php foreach($this->listWaterClass as $value){ ?>
        	                           <option value="<?php echo $value->WATM_CODE ?>" <?php if($value->WATM_CODE == $this->data['DOCK_WATM_CODE']){ echo "selected"; } ?> ><?php echo $value->WATM_NAME?></option>
                                    <?php }?>  
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right;font-size: 1.091em;padding-right:5px;" >利用水面名</td>
                            <td colspan="3"> <input type="text" value="<?php echo $this->data['DOCK_WNAME']; ?>" id="jform-dock-wname" name="jform[DOCK_WNAME]" style="width:80%;" /></td>
                        </tr>
                        <tr>
                            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">広域水面名</td>
                            <td colspan="3"> <input type="text" value="<?php echo $this->data['DOCK_WNAMEW']; ?>" id="jform-dock-wnamew" name="jform[DOCK_WNAMEW]" style="width:80%;" /></td>
                        </tr>
                        <tr>
                            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">水面利用備考</td>
                            <td colspan="3"> <input class="input medium" type="text" value="<?php echo $this->data['DOCK_WNOTE']; ?>" id="jform-dock-wnote" name="jform[DOCK_WNOTE]"  style="width:80%;" /></td>
                        </tr>
                        <tr>
                            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">水際状況<span class='err'></span></td>
                            <td colspan="3">
                            <!--  <input type="text" value="<?php echo $this->data['DOCK_SITUATION_BORDER']; ?>" name="jform[DOCK_SITUATION_BORDER]"  style="width:80%;" /> -->
                            <select name="jform[DOCK_DOWM_CODE]" class="inputbox">   
                              <option value="">選択してください</option>
                                <?php 
                                    foreach($this->getModel()->getDOWM() as $dowm){
                                        $selected = JRequest::getVar('jform[DOCK_DOWM_CODE]') == $dowm->DOWM_CODE ? 'selected' : '';
                                        echo "<option $selected value='$dowm->DOWM_CODE'>$dowm->DOWM_NAME</option>";
                                }
                             ?>    
                            </select>
                            </td>
                    </tr>
                    <tr>   
                        <td></td>
                        <td colspan="3" style="color: blue;font-size: 1.091em;">(推奨される画像の縦横比は「3:4」です。)</td>
                
                    </tr>
                    <tr>
                        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">艇庫</td>
                        <td style="width: 12%;">
                            <input type="file"  id="jformDOCK_IMGD" name="jformDOCK_IMGD" class="medium"  /> 
                            
                            <input type="hidden" name="jform[DOCK_IMGD_NEW]" id="value_DOCK_IMGD" value="" />
                        </td>
                        <td  style="text-align: right;font-size: 1.091em;">水際</td>
                        <td>
                            <input type="file" id="jformDOCK_IMGW" name="jformDOCK_IMGW" class="medium"  />
                            
                            <input type="hidden" name="jform[DOCK_IMGW_NEW]" id="value_DOCK_IMGW" value="" />
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td id="preview_IMGD"><img src="" id="showimg_IMGD" /></td>
                        <td></td>
                        <td id="preview_IMGW"><img src="" id="showimg_IMGW" /></td>
                    </tr>
                    <tr>
                        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">水面</td>
                        <td colspan="3" style="width: 7%;"> 
                            <input type="file" id="jformDOCK_IMGS" name="jformDOCK_IMGS" class="medium"  /> 
                              
                            <input type="hidden" name="jform[DOCK_IMGS_NEW]" id="value_DOCK_IMGS" value="" />
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td colspan="3" id="preview_IMGS"><img src="" id="showimg_IMGS" /></td>
                    </tr>
               </table>
            </fieldset>      
        </td>
    </tr> 
    <tr>
        <td colspan="5">
            <fieldset id="adminformfieldset">
                <legend>料金</legend>
               <table id="table_fee_list" border=0 >
                    <tr style="visibility:hidden">
                      <td style="width: 145px"></td>
                      <td style="width: 200px"></td>
                      <td style="width: 150px"></td>
                      <td style="width: 200px"></td>
                      <td style="width: 508px" ></td>
                    </tr>
                    <tr style="vertical-align:top;">
                        <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px;">町内大人</td>
                        <td style="vertical-align:top" >
                            <input type="text" vvName="money" value="<?php echo $this->data['DOCK_CIAD']; ?>" id="jform-dock-ciad" name="jform[DOCK_CIAD]" class="inputbox medium" />
                            <span name="msg_error"></span>
                        </td>
                        <td  style="text-align: right;font-size: 1.091em;vertical-align:top;line-height:30px;">町内子供</td>
                        <td style="vertical-align:top">
                            <input type="text" vvName="money" value="<?php echo $this->data['DOCK_CICI']; ?>" id="jform-dock-cici" name="jform[DOCK_CICI]" class="inputbox medium" />
                            <span name="msg_error"></span>
                        </td>
                    </tr>
                    <tr style="vertical-align:top;">
                        <td style="text-align: right;font-size: 1.091em;vertical-align:top;line-height:30px;">町外大人</td>
                        <td style="vertical-align:top">
                            <input type="text" vvName="money" value="<?php echo $this->data['DOCK_COAD']; ?>" id="jform-dock-coad" name="jform[DOCK_COAD]" class="inputbox medium" />
                            <span name="msg_error"></span>
                        </td>
                        <td style="text-align: right;font-size: 1.091em;vertical-align:top;line-height:30px;">町外子供</td>
                        <td style="vertical-align:top">
                            <input type="text" vvName="money" value="<?php echo $this->data['DOCK_COCI']; ?>" id="jform-dock-coci" name="jform[DOCK_COCI]" class="inputbox medium" />
                            <span name="msg_error"></span>
                        </td>
                    </tr>
                    <td style="text-align: right;font-size: 1.091em;padding-right:5px;vertical-align:top;line-height:30px;">備考</td>
                    <td colspan="3"> <input class="input medium" type="text" value="<?php echo $this->data['DOCK_CNOT']; ?>" id="jform-dock-cnot" name="jform[DOCK_CNOT]" style="width: 80.5%;" /></td>
               </table>
            </fieldset>
        </td>
    </tr>
    <tr>
        <td style="text-align: right;font-size: 1.091em;padding-right:5px;">備考</td>
        <td colspan="4"><textarea id="jform-dock-note" name="jform[DOCK_NOTE]" style="width: 57.5%;"><?php echo $this->data['DOCK_NOTE']; ?></textarea> </td>
    </tr>      
  </table>
  </div>
  
   <?php echo JHtml::_('tabs.end');?>
   	<div>
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="action" value="new" />
    </div>
   </form>
   
<?php $timestamp = time();?>
<script>

    
  
        $(function() {
            $('#jformDOCK_IMGD').uploadify({
                'formData'     : {
        			'timestamp' : '<?php echo $timestamp; ?>',
        			'token'     : '<?php echo md5('unique_salt' . $timestamp); ?>',
                    'DOCK_CODE' : '<?php echo $dockcode; ?>',
                    'STT'       : '1'
        		},
                'multi'    : false,
                'removeTimeout' : 1,
                'fileSizeLimit' : '125MB',
                'buttonText' : '画像を選択してください。',
                'width'    : 170,
                'swf'      : 'components/com_pgb/public/uploadlib/uploadify.swf',
                'uploader' : 'components/com_pgb/public/uploadlib/uploadify.php',           
                'onUploadSuccess' : function(file, data, response) {
                    
                    /* show image */
                    $('#preview_IMGD').html(
                    '<img style="width: 100px; height: 100px;" id="showimg_IMGD" src="uploads/images/com_pgb/'+data+'" />');
                    $('#value_DOCK_IMGD').val(data);
                }
                // Put your options here
            });
        });
        
        $(function() {
            $('#jformDOCK_IMGW').uploadify({
                'formData'     : {
        			'timestamp' : '<?php echo $timestamp; ?>',
        			'token'     : '<?php echo md5('unique_salt' . $timestamp); ?>',
                    'DOCK_CODE' : '<?php echo $dockcode; ?>',
                    'STT'       : '2'
        		},
                'multi'    : false,
                'removeTimeout' : 1,
                'fileSizeLimit' : '125MB',
                'buttonText' : '画像を選択してください。',
                'width'    : 170,
                'swf'      : 'components/com_pgb/public/uploadlib/uploadify.swf',
                'uploader' : 'components/com_pgb/public/uploadlib/uploadify.php',           
                'onUploadSuccess' : function(file, data, response) {
                    
                    /* show image */
                    $('#preview_IMGW').html(
                    '<img style="width: 100px; height: 100px;" id="showimg_IMGW" src="uploads/images/com_pgb/'+data+'" />');
                    $('#value_DOCK_IMGW').val(data);
                }
                // Put your options here
            });
        });
    
        $(function() {
            $('#jformDOCK_IMGS').uploadify({
                'formData'     : {
        			'timestamp' : '<?php echo $timestamp; ?>',
        			'token'     : '<?php echo md5('unique_salt' . $timestamp); ?>',
                    'DOCK_CODE' : '<?php echo $dockcode; ?>',
                    'STT'       : '3'
        		},
                'multi'    : false,
                'removeTimeout' : 1,
                'fileSizeLimit' : '125MB',
                'buttonText' : '画像を選択してください。',
                'width'    : 170,
                'swf'      : 'components/com_pgb/public/uploadlib/uploadify.swf',
                'uploader' : 'components/com_pgb/public/uploadlib/uploadify.php',           
                'onUploadSuccess' : function(file, data, response) {
                    
                    /* show image */
                    $('#preview_IMGS').html(
                    '<img style="width: 100px; height: 100px;" id="showimg_IMGS" src="uploads/images/com_pgb/'+data+'" />');
                    $('#value_DOCK_IMGS').val(data);
                }
                // Put your options here
            });
        });
        
     
        
        jq(document).ready(function() {
            /* add attribute for class="tabs" */
            jq( "#panel_1" ).parent().attr('id','tabs_1');
            jq( "#panel_2" ).parent().attr('id','tabs_2');
            jq( "#panel_3" ).parent().attr('id','tabs_3');
            
            /* jquery when change select box: gymt_2ndk */
            var gymt = jq('#jform-gymt_2ndk').val();
            if(gymt == 2){
                jq('#wrapper-gym2').css("display", "inline");
            }
            jq('#jform-gymt_2ndk').change(function(){
                var gymt = jq('#jform-gymt_2ndk').val();
                if(gymt == 2){
                    jq('#wrapper-gym2').css("display", "inline");
                }else{
                    jq('#wrapper-gym2').css("display", "none");
                }
            });
            
            
            
            //jq('#jformOCBA_CODE').autocomplete({source:'index.php?option=com_pgb&views=bg&task=searchOCBA_CODE', minLength:2});
            
            /* hide Pool - gymt - dock */
            
            var id = jq("#jformOCBA_CODE").val();
            if(id == ''){
                jq(".current").hide();
                jq("#mess").show();
                jq(".panel_1_id").hide();
                jq(".panel_2_id").hide();
                jq(".panel_3_id").hide();
                
                jq("#tabs_1").css('display','none');
                jq("#tabs_2").css('display','none');
                jq("#tabs_3").css('display','none');
                
            }else{
                var cc = id.substr(0,1);
                if(cc == 1){
                    jq(".current").show();
                    jq("#mess").hide();
                    jq(".panel_1_id").hide();
                    jq(".panel_2_id").hide();
                    jq(".panel_3_id").show();
                    
                    jq("#tabs_1").css('display','none');
                    jq("#tabs_2").css('display','none');
                    jq("#tabs_3").css('display','block');
                    
                    /* reset value tabs1 */
                    jq('#panel_1 input').each(function() {
                        jq(this).val('');
                    });
                    jq('#panel_1 checkbox').each(function() {
                        jq(this).attr('checked',false)
                    });
                    /* reset value tabs2 */
                    jq('#panel_2 input').each(function() {
                        jq(this).val('');
                    });
                    jq('#panel_2 checkbox').each(function() {
                        jq(this).attr('checked',false)
                    });
                }else{
                    jq(".current").show();
                    jq("#mess").hide();
                    jq(".panel_1_id").show();
                    jq(".panel_2_id").show();
                    jq(".panel_3_id").show();
                    
                    if(jq(".panel_1_id").attr("class") == "tabs panel_1_id open"){
                        jq("#tabs_1").css('display','block');
                    }else{
                        jq("#tabs_1").css('display','none');
                    }
                    if(jq(".panel_2_id").attr("class") == "tabs panel_2_id open"){
                        jq("#tabs_2").css('display','block');
                    }else{
                        jq("#tabs_2").css('display','none');
                    }
                    if(jq(".panel_3_id").attr("class") == "tabs panel_3_id open"){
                        jq("#tabs_3").css('display','block');
                    }else{
                        jq("#tabs_3").css('display','none');
                    }
                }
            }        
             
        });
        /* ajax show OCBA_CODE */
        /*jq(function(){
            jq("#jformOCBA_CODE").autocomplete({
              source: 'index.php?option=com_pgb&views=bg&task=searchOCBA_CODE'
            });
        });*/    
        
        /*show a dialog box: center search */
        jq('#link_ocba_code').bind('click', function(e){
            e.preventDefault();
                var id = jq("#ocba_code_old").val();
                zb = new jq.Zebra_Dialog('', {
                    source:  {'ajax': 'index.php?option=com_pgb&views=bg&task=popup_center&ocba_code_old='+id+'&tmpl=component'},
                    height: 800,
                    width: 550,
                    title:  'センター検索',
                    type:  '',
                    buttons:  [
                        {caption: '閉じる', callback: function() { }}
                            
                    ]
                });
            });
            
        /*select center id */
        jq(".link_ocba_code").live("click",function(){
            var id = jq(this).html();
            var cc = id.substr(0,1);
            if(cc == 1){
                jq(".current").show();
                jq("#mess").hide();
                jq(".panel_1_id").hide();
                jq(".panel_2_id").hide();
                jq(".panel_3_id").show();
                
                jq("#tabs_1").css('display','none');
                jq("#tabs_2").css('display','none');
                jq("#tabs_3").css('display','block');
                /* reset value tabs1 */
                jq('#panel_1 input[type="text"]').each(function() {
                    jq(this).val('');
                });
                jq('#panel_1 input[type="checkbox"]').each(function() {
                    
                    jq(this).removeAttr('checked');
                });
                /* reset value tabs2 */
                jq('#panel_2 input[type="text"]').each(function() {
                    jq(this).val('');
                });
                jq('#panel_2 input[type="checkbox"]').each(function() {
                    jq(this).removeAttr('checked');
                });
            }else{
                jq(".current").show();
                jq("#mess").hide();
                jq(".panel_1_id").show();
                jq(".panel_2_id").show();
                jq(".panel_3_id").show();
                
                if(jq(".panel_1_id").attr("class") == "tabs panel_1_id open"){
                    jq("#tabs_1").css('display','block');
                }else{
                    jq("#tabs_1").css('display','none');
                }
                if(jq(".panel_2_id").attr("class") == "tabs panel_2_id open"){
                    jq("#tabs_2").css('display','block');
                }else{
                    jq("#tabs_2").css('display','none');
                }
                if(jq(".panel_3_id").attr("class") == "tabs panel_3_id open"){
                    jq("#tabs_3").css('display','block');
                }else{
                    jq("#tabs_3").css('display','none');
                }
            }
            jq("#jformOCBA_CODE").val(id);
            centerName(id);
            checkCenter(id);
            zb.close();
            
        }); 
        
        /* select center name */
        function centerName(ocba_code){
            jq.get('index.php?option=com_pgb&task=ajax_get_name&tmpl=component&ocba_code='+ocba_code,function(result){
                jq('#jformOCBA_NAME').val(result);
            });  
        }
        /* Check center exist */
        function checkCenter(ocba_code){
            if(ocba_code == ''){
                jq('#resultCheck').html('');
                jq(".current").hide();
                //jq("#mess").show();
                jq(".panel_1_id").hide();
                jq(".panel_2_id").hide();
                jq(".panel_3_id").hide();
                
                jq("#tabs_1").css('display','none');
                jq("#tabs_2").css('display','none');
                jq("#tabs_3").css('display','none');
                
                return;
            }
            var ocba_code_old = jq("#ocba_code_old").val();
            var addnew = jq("#addnew").val();
            jq.get('index.php?option=com_pgb&task=checkCenter&tmpl=component&ocba_code='+ocba_code+'&ocba_code_old='+ocba_code_old+'&addnew='+addnew,function(result){
                jq('#resultCheck').html(result);
                //check result todo: show or hide center-club
                var check = jq('#check').val();
                if(check == 0){
                    jq(".current").hide();
                    //jq("#mess").show();
                    jq(".panel_1_id").hide();
                    jq(".panel_2_id").hide();
                    jq(".panel_3_id").hide();
                    
                    jq("#tabs_1").css('display','none');
                    jq("#tabs_2").css('display','none');
                    jq("#tabs_3").css('display','none');
                }else{
                    var id = jq("#jformOCBA_CODE").val();
                    var cc = id.substr(0,1);
                    if(cc == 1){
                        jq(".current").show();
                        jq("#mess").hide();
                        jq(".panel_1_id").hide();
                        jq(".panel_2_id").hide();
                        jq(".panel_3_id").show();
                        
                        jq("#tabs_1").css('display','none');
                        jq("#tabs_2").css('display','none');
                        jq("#tabs_3").css('display','block');
                        
                        /* reset value tabs1 */
                        jq('#panel_1 input[type="text"]').each(function() {
                            jq(this).val('');
                        });
                        jq('#panel_1 input[type="checkbox"]').each(function() {
                            
                            jq(this).removeAttr('checked');
                        });
                        /* reset value tabs2 */
                        jq('#panel_2 input[type="text"]').each(function() {
                            jq(this).val('');
                        });
                        jq('#panel_2 input[type="checkbox"]').each(function() {
                            jq(this).removeAttr('checked');
                        });
                        
                        
                    }else{
                        jq(".current").show();
                        jq("#mess").hide();
                        jq(".panel_1_id").show();
                        jq(".panel_2_id").show();
                        jq(".panel_3_id").show();
                        
                        if(jq(".panel_1_id").attr("class") == "tabs panel_1_id open"){
                            jq("#tabs_1").css('display','block');
                        }else{
                            jq("#tabs_1").css('display','none');
                        }
                        if(jq(".panel_2_id").attr("class") == "tabs panel_2_id open"){
                            jq("#tabs_2").css('display','block');
                        }else{
                            jq("#tabs_2").css('display','none');
                        }
                        if(jq(".panel_3_id").attr("class") == "tabs panel_3_id open"){
                            jq("#tabs_3").css('display','block');
                        }else{
                            jq("#tabs_3").css('display','none');
                        }
                        
                    }
                }
            });  
        }
    
    
    
    /* CALENDAR POOL */
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformPOOL_SDATE",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformPOOL_SDATE",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformPOOL_TDATE",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformPOOL_TDATE",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformPOOL_EDATE",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformPOOL_EDATE",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
    /* CALENDAR GYMT 1 */
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformGYMT_SDATE1",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformGYMT_SDATE1",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformGYMT_TDATE1",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformGYMT_TDATE1",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformGYMT_EDATE1",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformGYMT_EDATE1",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
    /* CALENDAR GYMT 2 */
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformGYMT_SDATE2",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformGYMT_SDATE2",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformGYMT_TDATE2",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformGYMT_TDATE2",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformGYMT_EDATE2",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformGYMT_EDATE2",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
    /* CALENDAR DOCK */
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformDOCK_SDATE",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformDOCK_SDATE",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformDOCK_TDATE",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformDOCK_TDATE",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
    window.addEvent('domready', function() {Calendar.setup({
        	// Id of the input field
        	inputField: "jformDOCK_EDATE",
        	// Format of the input field
        	ifFormat: "%Y/%m/%d",
        	// Trigger for the calendar (button ID)
        	button: "jformDOCK_EDATE",
        	// Alignment (defaults to "Bl")
        	align: "Bl",
        	singleClick: true,
        	firstDay: 0
    	});
    });
    
</script>